home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
COMMUNIC
/
COMMUTIL
/
2258.ZIP
/
ONCEONLY.ZIP
/
ONCEONLY.DOC
next >
Wrap
Text File
|
1990-05-05
|
7KB
|
166 lines
ONCEONLY.EXE V1.00
------------------
Batch File Utility
5th May 1990
Disclaimer
----------
This program is being put into the Public Domain and may be freely
distributed on the understanding that no responsibility can be
accepted for any problems arising from its use. To the best of our
knowledge, it is 'Bug free' and serves its intended purpose.
No charge, other than a nominal charge for duplication and postage may
be made for it and it should only be supplied as a single ARC or ZIP
file called ONCEONLY.ARC, or ONCEONLY.ZIP, containing the ONCEONLY.EXE
and ONCEONLY.DOC files.
Overview
--------
OnceOnly is a very simple program with one purpose. Every time it is
run, it returns an errorcode to the batch file from which it was
called. If the program has not been executed within the specified
number of days and the system time is later than the specified time,
it returns an errorlevel of 0, otherwise, an errorlevel of 1.
This provides a simple mechanism for determining whether part of the
batch file is to be executed or not, allowing you to only run certain
programs if they have not already been run within the specified
period and the time of day is later than the specified earliest time
of day.
OnceOnly is particularly useful in AUTOEXEC.BAT file which you might
only want to run a program after a certain period of time. An example
of this would be where you want to do a back up every 3, or 4 days,
for example. Using OnceOnly, AUTOEXEC.BAT can prompt you to back up,
or actually run your back up program.
Running ONCEONLY
----------------
ONCEONLY.EXE should be placed in any directory which is specified by
the PATH command.
The syntax used to run OnceOnly is:-
ONCEONLY <pathname> /nnn-hh:mm
<pathname> is required and must be the name of any file on any valid
drive and may include the full path and drive letter.
/nnn-hh:mm is required
'nnn' is the minimum number of days since OnceOnly last
returned an errorlevel of zero. Valid range is 1-
999.
'hh' is the earliest hour of the day at which the
program will return an errorlevel of zero.
'mm' is the earliest number of mins after the earliest
hour at which the program will return an
errorlevel of zero.
Note: 'hh' and 'mm' MUST each be two digit numbers,
separated by a colon ':' and must be separated
from the number of days by a hyphen '-'. Leading
zeros must be used, if necessary, for the hours
and minutes.
NOTE: The file specified by pathname may be a special file for the
purpose, or any existing file. Whenever OnceOnly is run, the
time and date stamp of the specified file are changed to the
current date and time of the computer's clock. You should not,
therefore, specify the name of a file for which it is important
that the date of that file is not changed!
The purpose of the 'earliest time' may not be immediately obvious, but
will be appreciated by Bulletin Board Sysops, in particular, as it
allows tasks such as back ups to be executed only after a certain time
of day/night when the BB software recycles after a caller logs off.
Most other users will probably choose to use 00:00 so that the event
happens, once only, at the start of each day.
What The Program Does
---------------------
Whenever ONCEONLY is run, the current file date of the specified file
is read and compared with the date according to the computer's system
clock and the frequency specified with '/nnn' if any. If the current
date, less the specified frequency, is earlier than the file date (a
greater period has elapsed, a check is made to see whether the system
time is later than the specified earliest time. If so, an Errorlevel
of 0 is returned, otherwise an Errorlevel of 1. This enables you to
check the errorlevel in the batch file, on return from the program and
to conditionally GOTO a different part of the batch file, depending on
the result. See the example batch file below.
If an Errorlevel of 0 is returned, the date/time stamp of the
specified file is updated to the current date/time.
OnceOnly makes use of a specified file rather than its own file
date/time stamp, so that it may be run from any number of different
batch files, or more than once in the same batch file, but always
compares the date and time with the specified file. This ensures that
it always returns the right answer. If its own date/time stamp was
used, the date/time would only be right once a day.
Example command lines
---------------------
ONCEONLY TEST.FLE /1-00:00 Repeat daily the first time after
midnight.
ONCEONLY TEST.FLE /7-00:00 Repeat weekly the first time after
midnight.
ONCEONLY TEST.FLE /2-12:00 Repeat every 2 days, but only if the
time is after midday. If it is more
than 2 days, an errorlevel of zero
will still be returned as long as the
time is after the specified earliest
time.
ONCEONLY TEST.FLE /365-00:00 Repeat once a year.
A Sample Batch File
-------------------
The following is an example of an AUTOEXEC.BAT file.
ECHO OFF
REM Execute the next few commands every time.
KEYB UK
PATH=C:\;C:\MSDOS;C:\SUNDRY
REM check if 7 days have passed and time is after midnight
ONCEONLY C:\AUTOEXEC.BAT /7-00:00
IF ERRORLEVEL==1 GOTO Cont
REM Execute the commands from here to Cont only if errorlevel==0
REM Insert programs to be periodically executed here.
:Cont
REM execute any further commands every time.
In the above example, the name of AUTOEXEC.BAT is used as the
parameter, but it could just as easily have been a dummy file
specially for the purpose, or any other file.
Update History
--------------
Version
1.00 - 03/05/90 - Initial release.
David Foster
H.L.C. Services
High Leys
Crook
Kendal
Cumbria
LA8 8LF
END